//
//  AboutUsVC.m
//  FindJob
//
//  Created by apple on 16/3/11.
//  Copyright © 2016年 Lee. All rights reserved.
//

#import "AboutUsVC.h"
#import "aboutUsCell.h"
#import "aboutCell.h"


static NSString *const kAboutCell = @"aboutCell";
static NSString *const kAboutUsCell = @"aboutUsCell";
@interface AboutUsVC ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, copy) NSArray *dataList;
@property (weak, nonatomic) IBOutlet UITableView *tabeView;

- (void)initializeUserIntefcace;  /**< 初始化用户界面 */
- (void)initializeDataSource;     /**< 初始化数据源 */

@end

@implementation AboutUsVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initializeDataSource];
    [self initializeUserIntefcace];
}
- (void)initializeDataSource{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"aboutUs" ofType:@"plist"];
    _dataList = [NSArray arrayWithContentsOfFile:path];
}
- (void)initializeUserIntefcace{
    UINib *aboutNib = [UINib nibWithNibName:NSStringFromClass([aboutCell class]) bundle:nil];
    [self.tabeView registerNib:aboutNib forCellReuseIdentifier:kAboutCell];
    
    UINib *aboutUsNib = [UINib nibWithNibName:NSStringFromClass([aboutUsCell class]) bundle:nil];
    [self.tabeView registerNib:aboutUsNib forCellReuseIdentifier:kAboutUsCell];
}
#pragma mark - <UITableViewDataSource,UITableViewDelegate>
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _dataList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        aboutUsCell *cell = [tableView dequeueReusableCellWithIdentifier:kAboutUsCell];
        cell.titleLabel.text = @"睿峰科技有限公司";
        cell.decribleLable.text = _dataList[indexPath.row];
        return cell;
    }else if (indexPath.row == 1){
        aboutCell *cell = [tableView dequeueReusableCellWithIdentifier:kAboutCell];
        cell.titleLabel.text = @"软件版本";
        cell.decriptionLabel.text = _dataList[indexPath.row];
        return cell;
    }else if (indexPath.row == 2){
        aboutCell *cell = [tableView dequeueReusableCellWithIdentifier:kAboutCell];
        cell.titleLabel.text = @"客服电话";
        cell.decriptionLabel.text = _dataList[indexPath.row];
        return cell;
    }else if (indexPath.row == 3){
        aboutCell *cell = [tableView dequeueReusableCellWithIdentifier:kAboutCell];
        cell.titleLabel.text = @"官方网址";
        cell.decriptionLabel.text = _dataList[indexPath.row];
        return cell;
    }else{
        aboutCell *cell = [tableView dequeueReusableCellWithIdentifier:kAboutCell];
        cell.titleLabel.text = @"隐私条款";
        cell.decriptionLabel.text = _dataList[indexPath.row];
        return cell;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
//        CGSize size = [self sizeOfString:_dataList[indexPath.row] size:CGSizeMake(self.tabeView.bounds.size.width, CGFLOAT_MAX) font:[UIFont systemFontOfSize:20]];
//        return size.height;
        return 480;
    }else{
        return 40;
    }
}
#pragma mark - private
-  (CGSize )sizeOfString:(NSString *)string size:(CGSize )size font:(UIFont *)font{
    
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
    style.lineBreakMode = NSLineBreakByCharWrapping;
    NSDictionary *attributes = @{NSFontAttributeName:font,NSParagraphStyleAttributeName:style};
    
    CGSize resultsize = [string boundingRectWithSize:size options: NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil].size;
    
    return resultsize;
}

@end
